package com.example.wjh.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import com.example.wjh.entity.Game;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface GameMapper extends BaseMapper<Game> {
    @Select("<script> " +
            "SELECT * FROM game " +
            "<where> " +
            "<if test='hometeamname != null'> AND hometeamname LIKE CONCAT('%', #{hometeamname}, '%')</if> " +
            "<if test='visitingteam != null'> AND visitingteam LIKE CONCAT('%', #{visitingteam}, '%')</if> " +
            "<if test='gameplace != null'> AND gameplace LIKE CONCAT('%', #{gameplace}, '%')</if> " +
            "</where> " +
            "</script>")
    List<Game> searchGame(
            @Param("hometeamname") String hometeamname,
            @Param("visitingteam") String visitingteam,
            @Param("gameplace") String gameplace
    );
}

